﻿using MVCTest.Models.EntityFrameWork;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;

namespace MVCTest.Helper
{
    public class UserHelper
    {
        public static bool Login(Users user)
        {
            using (MvcTestEntities context = new MvcTestEntities())
            {
                var users = context.Users.Where(q => q.UserName.Equals(user.UserName)
                                              && q.Password.Equals(user.Password));

                if (users != null && users.Count() == 1)
                {
                    return true;
                }
                else
                {
                    return false;
                }
                
            }
        }

        internal static void Register(Users user)
        {
            using (MvcTestEntities context = new MvcTestEntities())
            {
                context.Users.Add(user);
                context.SaveChanges();
            }
        }
    }
}